package com.allenkerr.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * Created by 小柯(Allen Kerr) on 17.6.3 22:23.
 */
//@Controller
//@ResponseBody
//@RestController = @Controller + @ResponseBody
@RestController
@RequestMapping(value = {"/hello", "/hi"})
public class HelloController {

    /*@Value("${girlCupSize}")
    private String girlCupSize;
    @Value("${girlName}")
    private String girlName;
    @Value("${girlAge}")
    private Integer girlAge;
    @Value("${girlContent}")
    private String girlContent;

    //@RequestMapping(value = "/say", method = RequestMethod.GET)
    //@GetMapping("/say") = @RequestMapping(value = "/say", method = RequestMethod.GET)
    @GetMapping("/say")
    public String sayHello() {
        return "content: {" + girlContent + "}";
//        return "name = " + girlName + ", age = " + girlAge + ", cup size = " + girlCupSize;
//        return "Girl Cup Size = " + girlCupSize;
//        return "Hello, Spring Boot!";
    }*/

    /*@Autowired
    private GirlProperties girlProperties;

    @GetMapping("/say")
    public String sayHello() {
//        return "index";//返回index.html
        return girlProperties.toString();
    }*/

    /*@GetMapping("/say/{id}")
    public String sayHello(@PathVariable(value = "id") Integer id) {
        return "ID = " + id;
    }*/

    @GetMapping("/say")
    public String sayHello(@RequestParam(value = "id", required = false, defaultValue = "0") Integer id) {
        return "ID = " + id;
    }

}
